package application;

import java.net.URL;
import java.util.ResourceBundle;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import modelo.ProfessorVO;
import util.Banco;
import util.ModelLocation;

public class Zoom implements Initializable {

	private Banco banco;
	private ModelLocation modelLocation = ModelLocation.getInstancia();
	
	@FXML private TableView tableConsulta;
	
	@FXML private TableColumn <ProfessorVO,String> codigoColumn;
	@FXML private TableColumn <ProfessorVO,String> nomeColumn;
	
	@FXML private TextField txiConsulta;
	
	
	@Override
	public void initialize(URL arg0, ResourceBundle arg1) {
		banco = Banco.getInstence();
		codigoColumn.setCellValueFactory(new PropertyValueFactory<ProfessorVO, String>("codigo"));
		nomeColumn.setCellValueFactory(new PropertyValueFactory<ProfessorVO, String>("nome"));
		tableConsulta.setItems(banco.getDados());
	}
	
	
	@FXML private void ok(ActionEvent event){
		ProfessorVO professorObj    = banco.getProfessor(tableConsulta.getSelectionModel().getSelectedItem());
		modelLocation.professorObj  = professorObj;
		modelLocation.getLister();
	}
	
	@FXML private void consultar(ActionEvent event){
		tableConsulta.setItems(banco.getConsulta(txiConsulta.getText()));
	}
}
